package com.hoangkien.service;

import java.util.ArrayList;

import com.hoangkien.DAO.CategoryDAO;
import com.hoangkien.DAO.CreateDatabase;
import com.hoangkien.DAO.ImageDAO;
import com.hoangkien.entity.CategoryEntity;
import com.hoangkien.entity.ImageEntity;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

public class CategoryService {
	private Context context;

	public CategoryService(Context context) {
		this.context = context;
	}

	public long insert_category(CategoryEntity categoryEntity) {
		CreateDatabase createDb = new CreateDatabase(context);
		SQLiteDatabase db = createDb.open();
		CategoryDAO categoryDAO = new CategoryDAO(db);
		long result = categoryDAO.insert_author(categoryEntity);
		db.close();
		createDb.close();
		return result;
	}

	public ArrayList<CategoryEntity> getAllCategory() {
		CreateDatabase createDb = new CreateDatabase(context);
		SQLiteDatabase db = createDb.open();
		CategoryDAO categoryDAO = new CategoryDAO(db);
		ArrayList<CategoryEntity> lisCategoryEntity = new ArrayList<CategoryEntity>();
		lisCategoryEntity = categoryDAO.getAllCategory();
		db.close();
		createDb.close();
		return lisCategoryEntity;
	}
}
